﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;


public partial class Admin_ConfirmReceipt : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                string barcode = Request.QueryString["barcode"];
                bindPackageDetail(barcode);
            }
            catch { ;} 
        }
    }

    private void ShowPdf(string filename)
    {
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("Content-Disposition", "inline;filename=" + filename);
        Response.ContentType = "application/pdf";
        Response.WriteFile(filename);
        Response.Flush();
        Response.Clear();
    }

    private void bindPackageDetail(int packageID)
    {
        BLLConfirmShipment bll = new BLLConfirmShipment();
        dlPackageDetail.DataSource = new List<vPackageDetail>() { bll.getPackageInformation(packageID) };
        dlPackageDetail.DataBind();
    }

    private void bindPackageDetail(string barcode)
    {
        BLLConfirmShipment bll = new BLLConfirmShipment();
        tblPackage package = bll.getPackageByBarcode(barcode);
        if (package != null)
        {
            bindPackageDetail(package.ID);
        }
        else
        {
            Response.Redirect("~/Staff/ScanReceipt.aspx");
        }

    }
   
}